package demo2;

public class test {
    public static void drawshape() {
        sanjiaoxing s=new sanjiaoxing();
        yuanxing y=new yuanxing();
        Flower flower=new Flower();
        Shape[] shapes={s,s,y,y,flower,flower};
        for(Shape shape:shapes){
            shape.draw();
        }
    }

    public static void drawshape2() {
        sanjiaoxing s=new sanjiaoxing();
        Flower flower=new Flower();
        yuanxing y=new yuanxing();
        String[] shapes={"sanjiaoxing","yuanxing","Flower","yuanxing","Flower"};
        for(String shape:shapes){
            if(shape.equals("yuanxing")){//是shape. 而不是shapes.
                 y.draw();
            }else if(shape.equals("Flower")){
                flower.draw();
            }else if(shape.equals("sanjiaoxing")){//三个都用if会每个都判断，如果用else if，如果成立的话，剩下的就不用看了，直接就跳出去了
                s.draw();
            }
        }
    }

    public static void drawshape1() {
        Shape[] shapes={new sanjiaoxing(),new yuanxing(),new yuanxing(),new Flower()
        ,new sanjiaoxing(),new Flower()};//向上转形
        for(Shape shape:shapes){
            shape.draw();
        }
    }
    public static void main(String[] args) {
//    sanjiaoxing s=new sanjiaoxing();
//    Flower flower=new Flower();
//    yuanxing y=new yuanxing();
//    s.draw();
//    flower.draw();
//    y.draw();
//    }
        drawshape();
    }





}
